/******************************************************************************
* This file is part of is32p218 platform,
* Copyright (c) 2009 HangZhou InfoStrong CO.,LTD. All rights reserved.
* This software may only be used under the terms of a valid, current,
* end user license from InfoStrong.
* Nothing else gives you the right to use this software.   
*
* Name:   app_plc.h
* Desc:   PLC Application layer header file
* Author: Jerry
* Date:   2009-10-30
* Note:   
* History:
*
******************************************************************************/
#include "def.h"
#include "isOS.h"
#include "sys_glb.h"
#include "drv_sys.h"

#ifndef __APP_PLC_H__
#define __APP_PLC_H__
#ifdef __cplusplus
extern "C" {
#endif

#if (defined(ZCP_DET_AUTO_SEL)&&(defined(XN5106C_EXT)))
#define ZCP_DET_CHK_ERR_CNT_MAX			8		// 8S
#define ZCP_DET_CHK_TMR_INTERVAL_FIRST	500		// 4S
#define ZCP_DET_CHK_TMR_INTERVAL		100		// 1S
#endif

typedef enum
{
	APP_PLC_TMR_ID_ZCP_DET_CHK = 0x00		// Zero detect check
}APP_PLC_TMR_ID_T;

typedef enum
{
	IO_ZCP_DET_A = 0,
	IO_ZCP_DET_B,
	IO_ZCP_DET_C
}IO_ZCP_DET;

typedef struct
{
#if (defined(ZCP_DET_AUTO_SEL)&&(defined(XN5106C_EXT)))
	isOS_TMR m_zcp_det_tmr;
	U8 m_zcp_det_cnt;
	IO_ZCP_DET m_zcp_x;				// ZCP_DET_A, ZCP_DET_B, or ZCP_DET_C
#else
	U8 m_res;						// Compile no error
#endif	
}APP_PLC_CTRL;


void app_plc_node_read_status( U16 *p_num_read, U16 *p_num_relay_read );

#if (!defined(MASTER_NODE))&&(defined(PHASE_SEQ_24_FLG))
void app_plc_phase_det_set( BOOL flg );
#endif

BOOL app_plc_init( U8 *p_mac_addr );
#ifdef __cplusplus
}
#endif

#endif	// End __APP_PLC_H__
